<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_modern
 * @copyright   Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Product view template
 *
 * @see Mage_Catalog_Block_Product_View
 * @see Mage_Review_Block_Product_View
 */
?>
<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct();
?>
   <div style="width:500px;float:left;margin-bottom: 50px;/*background-color:#E0E0E0;*/ margin-left: 1px;">
        <div style="width:260px; float:left;">
                <?php
                    $productId = $_product->getId(); 
                    $_product1 = Mage::getModel('catalog/product')->load($productId); //load the product
                ?>
           
             <div style="text-align: center;width: 205px;margin-left: 30px;margin-bottom: 5px;margin-top: 10px;">
                <span style="font-size: 12px;font-weight: bold;">
                    <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
                </span>
            </div>
            <div style="text-align: center">
                    <img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" border="0" width="250" height="250" />
                   
            </div>
           
                 <?php $regularprice=number_format($_product1->getPrice(), 2);$me = $this->getPriceHtml($_product, true);
					$specialprice= number_format($_product1->getFinalPrice(),2);
					$remainQty=  (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
 				 ?> 
          
        </div>
        <style>
            .line {
            height: 339px;
            margin-left: 271px;
            margin-top: 8px;
            position: absolute;
            width: 2px;
            }
        </style>
       <hr class="line" />
        <?php if ($_product->getShortDescription()):?>
                <div >

                    <div style="margin-left: 281px;margin-top: 3px; width: 200px;font-size: 13px">
                            <?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>
                    <?php echo $this->getChildHtml('product_review') ?>
                   </div>
                    <span style="font-size: 15px;margin-left: 20px">
                        <a href="<?php echo $_product1->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product1, 'image')) ?>"><span style="font-size: 13px;font-weight: bold">>>> more info </span></a>
                    </span> 
                </div>
            <?php endif;?>
       <div style="margin-left: 282px;margin-top: 10px;">
           <p style="color: #478BCC;font-size: 16px">Quantity Selection</p>
           <hr style="background-color: #000000; margin-top: -8px;width: 216px;margin-left: -7px"> </hr> 
           
            <div class="divStatistic">
          <span class="value">80% bought 1</span>
          <span class="bar" style="width:80%">80%</span>
            </div>
        <div class="divStatistic">
          <span class="value">14% bought 2</span>
          <span class="bar" style="width:14%">14%</span>
       </div>
       <div class="divStatistic">
          <span class="value">6% bought 3 or more</span>
          <span class="bar" style="width:6%">6%</span>
       </div>
       </div>
     
    </div>
   <div style="float:left;min-height:100px;width:312px;">
      
           
           <div style="width: 312px">
               <div style="float: left;width: 132px;padding-left: 10px;border: 1px #E0E0E0 solid" >
                   <div style="text-align: center;margin-bottom: 19px">
                   <a href="<?php echo $_product1->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product1, 'image')) ?>"><span style="font-size: 15px;font-weight: bold;color:#478BCC;">Weekly Deal</span></a>
                   </div>
                   <div style="text-align: center;font-size: 15px;font-weight: bold;margin-bottom: 24px">
                   <p>
                       <?php echo $this->__('$ ').$specialprice?>
                   </p>
                   </div>
               </div>
               <div style="float: right;width: 155px;padding-left: 10px" >
                         <div style="width: 140px">
                             <div style="float: left;width: 70px;margin-top: -19px">
                                   <br/>
                                    <p style="font-size: 13px;font-weight: bold;margin-bottom: 5px"> Value</p> 
                                    <p style="font-size: 13px;font-weight: bold"> Savings</p>
                                    
                            </div>
                           <div style="float: right;width: 79px;margin-top: -3px;margin-right: -13px" >
                                <span style="font-size: 15px;color:#478BCC;float:right;">$ <?php
                                $productId = $_product->getId(); 
                                $_product2 = Mage::getModel('catalog/product')->load($productId); //load the product
                                echo ($regularprice)//. number_format($_product2->getFinalPrice(),2)//. $this->formatDate( $_product->getSpecialToDate() , 'full' )?> </span><br>
                                <span style="font-size: 15px;color:#478BCC;margin-left: 38px;"><?php $discount =$specialprice*100/$regularprice;echo (int)$discount.'%'?></span>
                           </div>
                       </div>
                         <div style="    background-color: #EEEEEE;height: 23px;margin-top: 57px;padding-bottom: 5px;padding-top: 5px; text-align: center; width: 155px;">
                         <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
                             <button style="border:0px;font-size:15px" onclick="setLocation('<?php echo Mage::getUrl("/checkout/cart/add?product=133&qty=1")  ?>')" ><span><?php echo $this->__(' BUY NOW') ?></span></button>
                         </form>
                        <script type="text/javascript">
                            //<![CDATA[
                                    var productAddToCartForm = new VarienForm('product_addtocart_form');
                                    productAddToCartForm.submit = function(){
                                            if (this.validator.validate()) {
                                                    this.form.submit();
                                            }
                                    }.bind(productAddToCartForm);
                            //]]>
                         </script>
                        </div>
               </div>
           </div>
          
           <div style="text-align:center;margin-top: 100px" >
                <span style="font-size: 15px;font-weight: bold"> Time Remaining :</span>
				<p style="font-size: 15px;color:#478BCC">
                <!--                    <?php// echo $this->formatDate( $_product->getSpecialToDate() , 'full' );?><br>-->
                    <?php
                    $today=(double)time();
                    $endDate=(double)strtotime($_product->getSpecialToDate());
                    $remain=$endDate - $today;
                    $days =(int) ($difference/86400) ;
                    $dayre=floor($remain / 3600/24);
                    $remain %= (60 * 60 * 24);
                    $hre=floor($remain / 3600);
                    $remain %= (60 * 60);
                    $mre=floor(($remain % 3600) / 60);
                    $remain %= 60;
                    $sre=($remain % 60);
                     if($remain>0)
                    {
                    echo $dayre.'  days,  '.$hre.'  hours,  ' .$mre .' minutes';
                    }
                    else
                    {
                        echo '0  days,  '.' 0  hours,  ' .' 0  minutes';
                    }
                    ?>
					<!--                    <input id="remain" type="hidden" value="<?php// echo $endDate?>"></input>-->
                 </p>
           </div>
           
           <div style="width: 312px">
               <div style="  background-color: #E0E0E0;float: left;width: 132px;padding-left: 20px;text-align: center;" ><span style="font-size: 15px;">
				 <?php  
                               
                                   $resource1 = Mage::getSingleton('core/resource');
                                    $readConnection1 = $resource1->getConnection('core_read');
                                    $si = $resource1->getTableName('sales_flat_quote_item');
                                    $s0 = $resource1->getTableName('sales_flat_order');
                                    $productId1 = $_product->getId(); 
                                    $query2 ='SELECT qty From '.$si.'  Where  product_id = '.(int)$productId1 .' LIMIT 0,20';
                                  // $query1 ='SELECT qty From '.$si.' si join '.$s0 .' s0 on si.quote_id = s0.quote_id WHERE product_id = '.(int)$productId1 ;
                                    $_order_items = $readConnection1->fetchAll($query2); 
                                    $total = 0;
                                foreach($_order_items as $_order_item){ 
                                $qty = $_order_item['qty']; 
                                $total = $total + $qty; 
                                }
                                echo $total;
                                ?>
		 SOLD</span></div>
               <div style="  background-color: #EEEEEE; float: right;width: 150px;padding-left: 10px;text-align: center;"><span style="font-size: 15px;"><?php echo $remainQty ?> REMAINING</span></div>
               <div class="clear"></div>
           </div>
           <br/>
           <div style="border: 1px #E0E0E0 solid;margin-top: 20px;height: 166px;padding-left: 7px">
               <br>
               <p style="font-weight: bold;font-size: medium">Tell Others About This Deal</p> 
               <div style="width: 312px">
                   <div style="float: left;width: 150px" >
                       
                       <p><img alt="Email a friend" src="http://acetagco.nextmp.net/skin/frontend/default/acetag/images/social/email-icon.gif"></img> <a class="addthis_button_email" ><span style="color:#478BCC;"> Email a Friend>> </span></a></p>
                       <p><img alt="Facebook" src="http://acetagco.nextmp.net/skin/frontend/default/acetag/images/social/facebook_ico.png"></img><a class="addthis_button_preferred_rank"><span style="color:#478BCC;"> Share on Facebook>> </span></a></p>
                       <p><img alt="Twitter" src="http://acetagco.nextmp.net/skin/frontend/default/acetag/images/social/twitter_ico.png"></img><a class="addthis_button_twitter"> <span style="color:#478BCC;"> Share on Twitter>> </span></a></p>
                   </div>
                   <div style="float: right;width: 145px;padding-left: 10px">
                       <!-- AddThis Button BEGIN -->
                        <div >
                            <div><a class="addthis_button"></a></div><br>
<!--                            <div><a class="addthis_counter addthis_pill_style"></a></div><br>-->
                            <div><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></div>
                            
                             <!--<a class="addthis_button_tweet"></a>-->
                             <div><a class="addthis_button_google_plusone" g:plusone:size="medium"></a></div>

                        </div>
                        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f977e420184dc0d"></script>
                        <!-- AddThis Button END -->

                   </div>
               </div>
           </div>

     
       
       
       
       <style type="text/css">
           .divStatistic{
              font-size: 13px;
              width: 160px;
              position: relative;
              margin-top: 20px;
              padding: 2px;
           }
          .value
           {
               position: relative;
               z-index: 2;
           }
           .bar
           {
               height: 100%;
               left: 0;
               top: 0;
               overflow: hidden;
               position: absolute;
               background-color:#EEEEEE;
			   text-indent : -9999px;
           }
            .bar1
           {
               background-color:#E0E0E0 !important;
           }
       </style>
    </div> 

<div style="width: 300px;float: left; margin-left: 20px;border:1px #E0E0E0 solid;height:365px">
    <div style="text-align: center;background-color: #2B4987;color: #ffffff;margin-bottom: 1px;height: 25px;font-size: 15px;">
        <p >NEW ITEMS</p>
    </div>
    <div id="scrollbar_container">
		<div id="scrollbar_track"><div id="scrollbar_handle"></div></div>
		<div id="scrollbar_content">
			
                             <div style="margin-top:5px;margin-bottom: 5px; ">
                                <?php
                                    $resource = Mage::getSingleton('core/resource');
                                    $readConnection = $resource->getConnection('core_read');
                                    $table = $resource->getTableName('catalog_product_flat_1');
                                    $query ='SELECT entity_id, name, url_path From '.$table.' ORDER BY entity_id DESC LIMIT 0,20 ';
                                    $newitem = $readConnection->fetchAll($query); 
                                    foreach($newitem as $item)
                                    {
                                      
                                     $_product3 = Mage::getModel('catalog/product')->load($item['entity_id']);
                                     $url_path= $_product3->getProductUrl();
                                      echo '<div style="font-size:11px;border-bottom: 1px solid #E0E0E0; margin-left: 16px; margin-right: 16px; padding-bottom: 10px;padding-top: 5px;">';
                                      echo '<a href="'.$url_path.'" title="'.$item['name'].'">'.$item['name'] .'</a><br>';
                                      echo '</div>';
                                    }
                                 ?>
                             </div>                                
			</div>
		
	</div>
</div>
